import { detailApi } from "../utils/api";

const detailModule = {
  namespaced: true,
  state: {
    // 详情页数据
    detailInfo: {},
  },
  mutations: {
    // 改变detailInfo
    getDetail(state, payload) {
      state.detailInfo = payload.result;
    },
  },
  actions: {
    // 请求详情数据
    async getDetailAsync({ commit }, payload) {
      const res = await detailApi({
        id: payload.id,
      });
      // this.detailInfo = res.result;
      commit("getDetail", res);
    },
  },
};

export default detailModule;
